import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    meta: { title: '首页'},
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta:{title:'首页'}
    }]
  },

  {
    path: '/',
    component: Layout,
    name: 'PasswordChange',
    meta: { title: '密码修改'},
    children: [{
      path: '/password',
      name: 'Password',
      component: () => import('@/views/login/password'),
    }],
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    name: 'Bus',
    meta: { title: '商户管理'},
    children: [
      {
        path: '/busadmin',
        name: 'Busadmin',
        component: () => import('@/views/busadmin/busadmin'),
        meta: { title: '商户管理'}
      },
      {
        path: '/busadmin/bus-list',
        name: 'Busist',
        hidden: 'true',
        component: () => import('@/views/busadmin/bus-list'),
        meta: { title: '商户详情页' }
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Client',
    meta: { title: 'C端用户管理'},
    children: [
      {
        path: 'clinetList',
        name: 'ClientList',
        component: () => import('@/views/client/client'),
        meta: { title: 'C端用户管理列表' }
      },
      {
        path: '/clinetList/clientMes',
        name: 'ClientMes',
        hidden: 'true',
        component: () => import('@/views/client/clientMes'),
        meta: { title: 'C端用户详情' }
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Staff',
    meta: { title: '服务人员管理'},
    children: [
      {
        path: 'staffList',
        name: 'StaffList',
        component: () => import('@/views/staff/staff'),
        meta: { title: '服务人员管理' }
      },
      {
        path: 'staffList/staffMes',
        name: 'StaffMes',
        hidden: 'true',
        component: () => import('@/views/staff/staffMes'),
        meta: { title: '服务人员详情页' }
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Collage',
    meta: { title: '拼团管理'},
    children: [
      {
        path: 'collageList',
        name: 'CollageList',
        component: () => import('@/views/collage/collage'),
        meta: { title: '拼团管理'}
      },
      {
        path: 'collageAdd',
        name: 'CollageAdd',
        hidden: 'true',
        component: () => import('@/views/collage/collage-add'),
        meta: { title: '新增拼团' }
      },
      {
        path: 'collageMes',
        name: 'CollageMes',
        hidden: 'true',
        component: () => import('@/views/collage/collageMes'),
        meta: { title: '新增详情' }
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Need',
    meta: { title: '发布需求管理'},
    children: [
      {
        path: 'needList',
        name: 'NeedList',
        component: () => import('@/views/need/need'),
        meta: { title: '发布需求管理' }
      },
      {
        path: 'needMes',
        name: 'NeedMes',
        hidden: 'true',
        component: () => import('@/views/need/needMes'),
        meta: { title: '需求发布详情' }
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Server',
    meta: { title: '服务分类管理'},
    children: [
      {
        path: '/serverList',
        name: 'ServerList',
        component: () => import('@/views/server/server'),
        meta: { title: '服务分类管理' }
      },
      {
        path: '/serverList/serverTwo',
        name: 'ServerTwo',
        hidden: 'true',
        component: () => import('@/views/server/serverTwo'),
        meta: { title: '二级服务列表' }
      },
      {
        path: '/serverList/serverAddOne',
        name: 'ServerAddOne',
        hidden: 'true',
        component: () => import('@/views/server/serverAddOne'),
        meta: { title: '新增一级服务' }
      },
      {
        path: '/serverList/serverAddTwo',
        name: 'ServerAddTwo',
        hidden: 'true',
        component: () => import('@/views/server/serverAddTwo'),
        meta: { title: '新增二级服务' }
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Order',
    meta: { title: '订单管理'},
    children: [
      {
        path: 'orderList',
        name: 'OrderList',
        component: () => import('@/views/order/orderList'),
        meta: { title: '订单管理' }
      },
      {
        path: '/orderList/orderDetail',
        name:'OrderDetail',
        component: () => import('@/views/order/orderDetail'),
        hidden:true
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'Finance',
    meta: { title: '财务管理'},
    children: [
      {
        path: 'financeList',
        name: 'FinanceList',
        component: () => import('@/views/finance/finance-list'),
        meta: { title: '结算明细列表' }
      },
      {
        path: '/financeList/financeMes',
        name: 'FinanceMes',
        component: () => import('@/views/finance/finance-mes'),
        meta: { title: '结算明细详情' },
        hidden:true
      },
      {
        path: 'tradeList',
        name: 'TradeList',
        component: () => import('@/views/finance/trade-list'),
        meta: { title: '交易明细列表' }
      },
      {
        path: '/tradeList/tradeMes',
        name: 'TradeMes',
        component: () => import('@/views/finance/trade-mes'),
        meta: { title: '交易明细详情' },
        hidden:true
      },
      {
        path: 'refundList',
        name: 'RefundList',
        component: () => import('@/views/finance/refund-list'),
        meta: { title: '退款明细列表' }
      },
      {
        path: '/refundList/refundMes',
        name: 'RefundMes',
        component: () => import('@/views/finance/refund-mes'),
        meta: { title: '退款明细详情' },
        hidden:true
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    name: 'AdminList',
    meta: { title: '管理员'},
    children: [
      {
        path: 'admin',
        name: 'Admin',
        component: () => import('@/views/admin/admin'),
        meta: { title: '角色的权限管理' }
      },
      {
        path: '/admin/adminAdd',
        name: '/admin/AdminAdd',
        component: () => import('@/views/admin/adminAdd'),
        meta: { title: '添加管理员' },
        hidden: true
      }
    ]
  },

  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //   name: 'nested',
  //   meta: {
  //     title: 'nested',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'menu1',
  //       meta: { title: 'menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'menu1-1',
  //           meta: { title: 'menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'menu1-2',
  //           meta: { title: 'menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'menu1-2-1',
  //               meta: { title: 'menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'menu1-2-2',
  //               meta: { title: 'menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'menu1-3',
  //           meta: { title: 'menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
